package com.nidu.demo.notify;

import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.nidu.demo.common.enums.UserTypeEnum;
import com.nidu.demo.notify.api.SysNotifyMessageService;
import com.nidu.demo.notify.dto.*;
import com.nidu.demo.notify.executor.command.*;
import com.nidu.demo.notify.executor.query.*;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * 站内信消息服务实现类
 *
 * @author auto
 */
@Service
@RequiredArgsConstructor
public class SysNotifyMessageServiceImpl implements SysNotifyMessageService {

    private final NotifyMessageAddCmdExe addCmdExe;
    private final NotifyMessageUpdateCmdExe updateCmdExe;
    private final NotifyMessageDeleteCmdExe deleteCmdExe;
    private final NotifyMessageSingleQryExe singleQryExe;
    private final NotifyMessagePageQryExe pageQryExe;

    @Override
    public Response send(UserTypeEnum userType, NotifyMessageSendCmd cmd) {
        return addCmdExe.execute(userType, cmd);
    }

    @Override
    public Response send(UserTypeEnum userType, Set<Long> userIds, NotifyMessageSendCmd cmd) {
        return addCmdExe.execute(userType, userIds, cmd);
    }

    @Override
    public Response updateReadStatus(Long id) {
        return updateCmdExe.updateReadStatus(id);
    }

    @Override
    public Response updateReadStatus(Set<Long> ids) {
        return updateCmdExe.updateReadStatus(ids);
    }

    @Override
    public Response delete(Long id) {
        return deleteCmdExe.execute(id);
    }

    @Override
    public Response delete(Set<Long> ids) {
        return deleteCmdExe.execute(ids);
    }

    @Override
    public SingleResponse<NotifyMessageCO> getById(Long id) {
        return singleQryExe.execute(id);
    }

    @Override
    public PageResponse<NotifyMessageCO> page(NotifyMessagePageQry qry) {
        return pageQryExe.execute(qry);
    }

}
